/*******************************************************************************
 * Copyright (c) 2008-2010 Cedric Vidal
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Cedric Vidal - original idea, initial contribution and API
 *******************************************************************************/
package org.trans4j.impl;

import java.lang.reflect.Method;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;

public class Hasher {

	public Integer hash(Method method, Object... args) {
		Class<?>[] types = method.getParameterTypes();
		Object[] keys = new Object[args.length + 1 + types.length];
		System.arraycopy(args, 0, keys, 1, args.length);
		System.arraycopy(types, 0, keys, args.length + 1, types.length);
		keys[0] = method.getDeclaringClass().getName() + "#" + method.getName();
		Integer argsHash = hash(keys);
		return argsHash;
	}

	protected int hash(Object[] keys) {
		return Arrays.hashCode(keys);
	}

}
